//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.quickserver.net.qsadmin.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SaveActionListener implements ActionListener {
    private Propertie propertie;
    private QSAdminMain qsadminMain;

    public SaveActionListener(QSAdminMain qsadminMain, Propertie propertie) {
        this.qsadminMain = qsadminMain;
        this.propertie = propertie;
    }

    public void actionPerformed(ActionEvent e) {
        Thread performer = new Thread(new Runnable() {
            public void run() {
                String temp = null;
                if (SaveActionListener.this.propertie.getType().equals("edit")) {
                    temp = SaveActionListener.this.propertie.getEditField().getText();
                } else if (SaveActionListener.this.propertie.getType().equals("select")) {
                    temp = (String)SaveActionListener.this.propertie.getComboBox().getSelectedItem();
                }

                if (SaveActionListener.this.qsadminMain.getServerVersionNo() < SaveActionListener.this.propertie.getVersionNo()) {
                    SaveActionListener.this.qsadminMain.getGUI().setResponse("-ERR Host does not support this command");
                } else {
                    try {
                        temp = SaveActionListener.this.qsadminMain.sendCommunicationSilent(SaveActionListener.this.propertie.getSetCommand(temp), false, true);
                        SaveActionListener.this.propertie.getSaveButton().setEnabled(false);
                    } catch (Exception var3) {
                        temp = "-ERR Could not set parameter : " + var3.getMessage();
                    }

                    if (temp != null) {
                        if (temp.indexOf(" ") == -1) {
                            SaveActionListener.this.qsadminMain.getGUI().setResponse("-ERR " + temp);
                        } else {
                            SaveActionListener.this.qsadminMain.getGUI().setResponse(temp);
                        }
                    }
                }
            }
        }, "QsAdminGUI-SaveThread");
        performer.start();
    }
}
